<template>
  <div :class="className" :style="{height:height,width:width}" />
</template>

<script>
import echarts from "echarts";
require("echarts/theme/macarons"); // echarts theme
import resize from "./mixins/resize";
import "echarts/map/js/china"; // 引入中国地图数据
export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: "chart"
    },
    width: {
      type: String,
      default: "100%"
    },
    height: {
      type: String,
      default: "100%"
    }
  },
  data() {
    return {
      chart: null
    };
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart();
    });
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, "macarons");
      this.chart.setOption({
        backgroundColor: "#151b53",
        tooltip: {
          trigger: "item"
        },
        geo: {
          map: "china",
          right: "2%",
          left: "2%",
          label: {
            normal: {
              show: true,
              color: "#216ca7"
            },
            emphasis: {
              show: false
            }
          },
          roam: true,
          itemStyle: {
            normal: {
              areaColor: "#172260",
              borderColor: "#216ca7",
              borderWidth: 1,
              shadowColor: "#216ca7",
              shadowBlur: 1
            },
            emphasis: {
              show: false
            }
          },
          silent: true
        },
        series: [
          {
            type: "effectScatter",
            coordinateSystem: "geo",
            data: [
              {
                name: "合肥",
                value: [117.215201,31.843399],
              }
            ],
            symbolSize: 30,
            showEffectOn: "render",
            rippleEffect: {
              brushType: "stroke"
            },
            hoverAnimation: true,
            label: {
              normal: {
                formatter: "{b}",
                position: "right",
                color:"#91c7ae",
                show: true,
               fontSize:25
              }
            },
            zlevel: 1
          }
        ]
      });
    }
  }
};
</script>
